package ink.metoo.gude.controller

import ink.metoo.gude.aspect.RateLimit
import ink.metoo.gude.util.ApiUtils
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.util.concurrent.TimeUnit

@RestController
@RequestMapping("/test/rate-limit-test")
class RateLimitTestController {

    @RateLimit(
        max = 1,
        duration = 1L,
        timeUnit = TimeUnit.SECONDS,
        key = RateLimit.Key.IP,
        type = RateLimit.Type.ALL
    )
    @GetMapping("/limit-ip-all")
    fun test() = ApiUtils.run { }

}